package io.gitee.twoke.generator.engine.impl.generate.method.impl;

import io.gitee.twoke.generator.engine.impl.generate.DataTableColumn;
import io.gitee.twoke.generator.engine.impl.generate.method.GlobalMethod;
import org.apache.commons.lang3.StringUtils;

public interface EntityGlobalMethod extends GlobalMethod {
    static EntityGlobalMethod instance() {
        return new EntityGlobalMethod() {

            private String capitalize(String name) {
                return StringUtils.capitalize(name);
            }

            @Override
            public String i_getter(DataTableColumn column) {
                return column.getJavaType()+" get"+capitalize(column.getJavaProperty())+"();";
            }

            @Override
            public String i_setter(DataTableColumn column) {
                return "void set"+capitalize(column.getJavaProperty())+"("+column.getJavaType()+" "+column.getJavaProperty()+");";
            }

            @Override
            public String e_getter(DataTableColumn column) {
                return "public "+column.getJavaType()+" get"+capitalize(column.getJavaProperty())+"() {\n\t\t return this."+column.getJavaProperty()+";\n\t}";
            }

            @Override
            public String e_setter(DataTableColumn column) {
                return "public void set"+capitalize(column.getJavaProperty())+"(" +column.getJavaType()+" "+column.getJavaProperty()+
                        ") {\n\t\t this."+column.getJavaProperty()+"="+column.getJavaProperty()+";\n\t}";
            }

            @Override
            public String e_field(String flag, DataTableColumn column) {
                return flag + " " + column.getJavaType() + " " + column.getJavaProperty() + ";";
            }

            @Override
            public String e_field(DataTableColumn field) {
                return e_field("private", field);
            }
        };
    }

    String e_getter(DataTableColumn column);
    String e_setter(DataTableColumn column);
    String i_getter(DataTableColumn column);
    String i_setter(DataTableColumn column);
    String e_field(String flag, DataTableColumn column);
    String e_field(DataTableColumn field);

}